Skip to content

fix(context): 修复 metadata-only 工具结果语义丢失#307

Merged
phantom5099 merged 2 commits into
1024XEngineer:mainfrom
wynxing:codex/fix-metadata-tool-result-projection
Apr 15, 2026
Merged

fix(context): 修复 metadata-only 工具结果语义丢失#307
phantom5099 merged 2 commits into
1024XEngineer:mainfrom
wynxing:codex/fix-metadata-tool-result-projection

Conversation

@wynxing

@wynxing wynxing commented Apr 15, 2026

Copy link
Copy Markdown
Collaborator

背景

修改

  • 放宽 context 对 tool message 的读时注入/投影条件,使 metadata-only 成功结果也能投影为结构化文本。
  • 在 runtime 写入会话消息前增加最小归一化:为完全空语义的成功结果补齐 \ok\,并在 result.Name 为空时回填 call.Name。
  • 补充 context、runtime、memo、session 的回归测试,并修复 runtime 测试中被弱化的事件断言与手写投影 helper。

测试

  • go test ./internal/context ./internal/runtime ./internal/memo ./internal/session

Fixes #306

@codecov

codecov Bot commented Apr 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

fennoai[bot]

This comment was marked as outdated.

fennoai[bot]

This comment was marked as outdated.

fennoai[bot]

This comment was marked as outdated.

fennoai[bot]

This comment was marked as outdated.

@wynxing

wynxing commented Apr 15, 2026

Copy link
Copy Markdown
Collaborator Author

/simplify

fennoai[bot]

This comment was marked as outdated.

@fennoai

fennoai Bot commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

完成结果

  • 已读取历史评论并处理未解决项:internal/runtime/session_mutation.go 中重复调用 SanitizeToolMetadata 的问题已修复。
  • 已按要求进行简化审查:调用 code-simplifier 子代理后,确认当前实现已足够精简,无需进一步改动。
  • 已新增回归测试,覆盖“仅保留 tool_name 的成功工具结果应归一化为 ok”场景。

具体改动

  • internal/runtime/session_mutation.go
  • internal/runtime/runtime_internal_helpers_test.go

核心调整:

  • 归一化逻辑改为复用一次 sanitizedMetadata,避免二次 sanitize 与潜在语义分叉。
  • 新增 hasNonToolNameToolMetadata 辅助判断,明确“是否存在除 tool_name 外的语义 metadata”。

验证

  • go test ./internal/runtime
  • go test ./internal/context ./internal/runtime ./internal/memo ./internal/session

提交与推送

  • Commit: ad20555
  • 已推送到 PR 分支:Yumiue:codex/fix-metadata-tool-result-projection

未执行项:无。

View job run

…lization

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: Yumiue <188874804+Yumiue@users.noreply.github.com>
@phantom5099

Copy link
Copy Markdown
Collaborator

/review

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

审查完成:整体实现与测试覆盖较完整,未发现功能性、性能或安全问题。

仅有 1 个低风险可维护性问题,建议在本 PR 内一并修正。

Comment thread internal/runtime/session_mutation.go
@phantom5099 phantom5099 merged commit cbd9160 into 1024XEngineer:main Apr 15, 2026
2 checks passed
@fennoai fennoai Bot mentioned this pull request Apr 15, 2026
@wynxing wynxing deleted the codex/fix-metadata-tool-result-projection branch April 20, 2026 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(runtime):修复ToolManager content可能为空

3 participants